package com.vector.demo.controller.admin;

import com.vector.demo.pojo.QueryGradeInfo;
import com.vector.demo.pojo.Student;
import com.vector.demo.service.GradeService;
import com.vector.demo.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/admin")
public class GradeManagementController {

    @Autowired
    private GradeService gradeService;

    @Autowired
    private StudentService studentService;

    /**
     * 成绩管理
     * @return
     */
    @RequestMapping("/gradeManagementController")
    public String gradeManagementController(Model model) {
        List<QueryGradeInfo> gradeList = gradeService.queryAllGrade();
        model.addAttribute("gradeList", gradeList);
        return "admin/GradeManagement/gradeManagement";
    }

    /**
     * 预修改
     * @return
     */
    @RequestMapping("/preModifyGradeManagementController")
    public String modifyGradeManagementController(Model model,int id) {
        QueryGradeInfo queryGradeInfo = gradeService.queryByIdGrade(id);
        model.addAttribute("queryGradeInfo", queryGradeInfo);
        return "admin/GradeManagement/preModifyGradeManagement";
    }
    /**
     * 更新
     */
    @RequestMapping("/modifyGradeManagementController")
    public String modifyGradeManagementController(Model model,double grade, int id) {
        gradeService.modifyByIdGrade(id, grade);
        return "admin_index";
    }

}
